<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加联系人</title>
</head>
<body>
    <p onclick="addWxContact(null,null)">关注</p>
</body>

<script type="text/javascript">
    var addWxContact = function(wxid, cb)
    {
        if (typeof WeixinJSBridge == 'undefined') return false;
        WeixinJSBridge.invoke('addContact', {
            webtype: '1',
            username: 'gh_511b7041c1c5'
        }, function(d) {
            // 返回d.err_msg取值，d还有一个属性是err_desc
            // add_contact:cancel 用户取消
            // add_contact:fail　关注失败
            // add_contact:ok 关注成功
            // add_contact:added 已经关注
            WeixinJSBridge.log(d.err_msg);
            cb && cb(d.err_msg);
        });
    };
</script>
</html>